﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Fraktalysator.Forms
{
	partial class UpdateInfoBox : ArgusLib.Controls.BaseForm
	{
		int clientWidth;

		public UpdateInfoBox()
		{
			InitializeComponent();
		}

		public static void ShowUpdates(IEnumerable<UpdateInfo> updateInfos)
		{
			UpdateInfoBox box = new UpdateInfoBox();
			box.AutoScroll = true;
			int width = 0;
			int vScrollWidth = SystemInformation.VerticalScrollBarWidth;
			foreach (UpdateInfo info in updateInfos)
			{
				Controls.UpdateInfoDisplay display = new Controls.UpdateInfoDisplay();
				display.UpdateInfo = info;
				box.stackPanel1.Controls.Add(display);
				width = Math.Max(width, display.Width + display.Margin.Horizontal);
			}
			box.clientWidth = width;
			box.ClientSize = new Size(width, Math.Min(400, box.stackPanel1.Bottom+box.stackPanel1.Margin.Bottom));
			box.ShowDialog();
		}

		protected override void OnResize(EventArgs e)
		{
			int vScrollWidth = 0;
			if (this.VScroll == true)
				vScrollWidth = SystemInformation.VerticalScrollBarWidth;
			this.ClientSize = new Size(this.clientWidth+vScrollWidth, this.ClientSize.Height);
			base.OnResize(e);
		}
	}
}
